
5. APPENDIX 40
{
//creates a 1 by 1 rectangle
Int32Rect rect = new Int32Rect(x,y, 1, 1);
//subdata is an array of the bgra values at a pixel
byte[] subdata = { data[x * 4 + stride * y],
data[x * 4 + stride * y + 1],
data[x * 4 + stride * y + 2],
data[x * 4 + stride * y + 3] };
byte b = 255;
byte g = 255;
byte r = 255;
byte a = 0;
byte[] transparent = { b, g, r, a };//transparent pixel
byte ItemDepth = 0; //can be changed to a higher value,
//Any depth lower than this value is hidden from the
//image being added to the camera feed (lower values
//coorespond to higher depths)
//SECTION 1-----------------------------------------
if ((subdata[1]<= 250&& depth[(y*stride + x*4)] == ItemDepth)
&& (depth[(y*stride + x*4) + 1] == ItemDepth)
&& (depth[(y*stride + x*4) + 2] == ItemDepth))
target.WritePixels(rect, subdata, stride, 0);
//SECTION 1-----------------------------------------
//SECTION 2-----------------------------------------
/* //If ItemDepth is changed from 0, comment section 1 and
//uncomment this section, section 2
if ((subdata[1] <= 250 && depth[(ystride + x*4)] <= ItemDepth)
&& (depth[(y*stride + x*4) + 1] <= ItemDepth)
&& (depth[(y*stride + x*4) + 2]<= ItemDepth))
target.WritePixels(rect, subdata, stride, 0);
*/
//SECTION 2-----------------------------------------
//target.WritePixels(rect, transparent, stride, 0);
//writes transparent pixels
}
}
//-------------------------------------------------------LOOP(END)
return target; //returns a WriteableBitmap object
}
}
}
//END OF CLASS**